<?php
namespace app\admin\model;

class Admin extends \think\Model
{
    
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected $auto = [];
//    protected $update = ['login_ip'];

    protected $readonly = ['username'];

    protected function setSaltAttr($value) {
        return $value ?: \fast\Random::nozero(6);
    }

    protected function setLoginIpAttr($value, $data) {
        return $value ?: request()->ip;        
    }

    // protected function authGroup() {
    //     return $this->hasMany('AuthGroup', 'id', 'group_id');
    // }


    protected function groupAccess() {
        return $this->hasMany('auth_group_access','uid', 'id');
    }
}